﻿#include "StatisticsEntity.h"
#include <QDate>
#include <QJsonDocument>
#include <QUuid>
#include <SqliteDatabase.h>
#include <QDebug>
StatisticsEntity::StatisticsEntity():
    mId(QUuid::createUuid().toString())
  ,mDate(QDate::currentDate().toString("yyyy-MM-dd"))
{

}

//转成JSon需要的数据对象
QVariant StatisticsEntity::toVariant() const
{
   QVariantMap map;
   map.insert("id",mId);
   map.insert("date", mDate);
   map.insert("data", mData);
   return map;
}

//通过数据对象实现类
void StatisticsEntity::fromVariant(const QVariant &variant)
{
    QVariantMap map = variant.toMap();
    mId = map.value("id").toString();
    mDate = map.value("date").toString();
    mData = map.value("data").toJsonObject();
}




